package com.pitop.login.ctrl;

import com.pitop.account.entity.Account;
import com.pitop.account.service.AccountSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/login")
@Slf4j
@Api(value = "登录账号验证控制器", description = "登录账号验证控制器")
public class LoginCtrl {


    @Autowired
    private AccountSV accountSV;

    @ApiOperation(value = "根据账号和密码查询", notes = "根据账号和密码查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "account", value = "account", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "password", value = "password", paramType = "query", dataType = "String")
    })
    @RequestMapping(value = "/loadByAccountAndPwd", method = RequestMethod.GET)
    @ResponseBody
    public Account loadByAccountAndPwd(String account, String password) {
        if (StringUtils.isBlank(account)) {
            return null;
        }
        if (StringUtils.isBlank(password)) {
            return null;
        }
        Account accountObj = accountSV.loadByAccountAndPwd(account, password);
        return accountObj;
    }

}
